#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node *nodeptr;
typedef struct node {
    char    *word;
    int     count;
    nodeptr next;
} node;

#define MAXWORD 1024
#define NHASH   29989
#define MULT    31
nodeptr bin[NHASH];

unsigned int hash(char *p)
{
    unsigned int h = 0;
    for (; *p != '\0'; p++)
        h = h*MULT + *p;
    
    return h%NHASH;
}

void incword(char *p)
{
    int     i;
    nodeptr np;

    i = hash(p);
    np = bin[i];
    while (np != NULL && strcmp(np->word, p))
        np = np->next;

    if (np == NULL) {
        np = malloc(sizeof(node));
        np->word = malloc(strlen(p)+1);
        strcpy(np->word, p);
        np->count = 1;
        np->next = bin[i];
        bin[i] = np;
    }
    else
        np->count ++;
}

int main(int argc, char *argv[])
{
    int     i;
    char    buf[MAXWORD];
    nodeptr np;

    for (i = 0; i < NHASH; i++)
        bin[i] = 0;

    while (scanf("%s", buf) != EOF)
        incword(buf); 

    for (i = 0; i < NHASH; i++) {
        np = bin[i];
        while (np != NULL) {
            printf("%s %d\n", np->word, np->count);
            np = np->next;
        }
    }

    return 0;
}

